<template>
    <div class="pxx-container">
        <!-- 顶部Header区域 -->
    <mt-header fixed title="拼夕夕">
        <span slot="left" @click="goBack" v-show="flag">
            <mt-button icon="back">返回</mt-button>
        </span>
    </mt-header>

        <!-- 中间的路由 router-view 区域 -->
        <transition>
            <router-view></router-view>
        </transition>

        <!-- 底部 Tabbar 区域 -->
        <nav class="mui-bar mui-bar-tab">
			<router-link class="mui-tab-item-gl" to="/home">
				<span class="mui-icon mui-icon-home"></span>
				<span class="mui-tab-label">首页</span>
			</router-link>
			<router-link class="mui-tab-item-gl" to="/classify">
				<span class="mui-icon mui-icon-paperplane"></span>
				<span class="mui-tab-label">分类</span>
			</router-link>
			<router-link class="mui-tab-item-gl" to="/shopcar">
				<span class="mui-icon mui-icon-extra mui-icon-extra-cart"><span class="mui-badge">9</span></span>
				<span class="mui-tab-label">购物车</span>
			</router-link>
			<router-link class="mui-tab-item-gl" to="/personal">
				<span class="mui-icon mui-icon-contact"></span>
				<span class="mui-tab-label">个人中心</span>
			</router-link>
		</nav>
    </div>
</template>

<script>
export default {
    data() {
        return {
            flag : false,
        }
    },
    created() {
        this.flag = this.$route.path === "/home" ? false : true;
    },
    methods : {
        goBack() {
            // 点击后退
            this.$router.go(-1);
        }
    },
    watch : {
        "$route.path" : function(newVal){
            if(newVal === "/home" || newVal === "/") {
                this.flag = false;
            }else {
                this.flag = true;
            }
        }
    }
}
</script>

<style lang="less" scoped>
@import './less/main.less';

.pxx-container {
    padding-top: 80/@bs;
    padding-bottom: 100/@bs;
    overflow-x: hidden;

    .v-enter {
        opacity: 0;
        transform: translateX(100%);
    }

    .v-leave-to {
        opacity: 0;
        transform: translateX(-100%);
        position: absolute;
    }

    .v-enter-active,
    .v-leave-active {
        transition: all 0.3s ease;
    }

    .mint-header{
        background-color: @pxxColor;
        z-index: 99;
        font-size: 28/@bs;
        height: 80/@bs;

        .mint-button {
            height: 82/@bs;
            border-radius: 8/@bs;
            margin-left: 20/@bs !important;
        }
    }
    // 该类名，解决 tabbar 点击无法切换的问题
    .mui-bar-tab .mui-tab-item-gl.mui-active {
        color: @pxxColor;
    }

    .mui-bar-tab .mui-tab-item-gl {
        display: table-cell;
        overflow: hidden;
        width: 1%;
        height: 100/@bs;
        text-align: center;
        vertical-align: middle;
        white-space: nowrap;
        text-overflow: ellipsis;
        color: #929292;

        .mui-icon {
            top: 6/@bs;
            width: 48/@bs;
            height: 48/@bs;
            padding-top: 0;
            padding-bottom: 0;
            font-size: 48/@bs;

            .mui-badge{
                font-size: 20/@bs;
                top: -4/@bs;
                margin-left: -20/@bs;
                padding: 2/@bs 10/@bs;
                border-radius: 200/@bs;
            }
        }

        .mui-icon ~ .mui-tab-label {
            font-size: 22/@bs;
            display: block;
            overflow: hidden;
            text-overflow: ellipsis;
        }
    }
}
</style>

